package com.night.utils;

import com.night.context.AnnotationConfigApplicationContext;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;

import java.util.Objects;

/**
 * @Author: chen yang
 * @Date: 2024/12/4 20:33
 */
public class ApplicationContextUtils {

    private static AnnotationConfigApplicationContext applicationContext = null;

    @Nonnull
    public static AnnotationConfigApplicationContext getRequiredApplicationContext() {
        return Objects.requireNonNull(getApplicationContext(), "ApplicationContext is not set.");
    }

    @Nullable
    public static AnnotationConfigApplicationContext getApplicationContext() {
        return applicationContext;
    }

    public static void setApplicationContext(AnnotationConfigApplicationContext ctx) {
        applicationContext = ctx;
    }
}
